/**
 * 弹出窗口
 */

import { loadVue } from './LoadHtml.js';

let vue = undefined;

async function createDialog() {
    if (vue) return vue;

    await loadVue('./views/dialog.vue', 'dialog1027-container');

    vue = new Vue({
        el: "#dialog1027",
        data() {
            return {
                dialogVisible: false,
                title: "提示",
                message: "",
                autosize: { minRows: 1, maxRows: 10 },
                containerWidth: "600px"
            };
        },
        methods: {
            handleClose(done) {
                done();
            },
            ok() {
                this.dialogVisible = false;
                if (this._callback) this._callback(this.message);
            },
            show(message, title, callback, _width, _height) {
                this.dialogVisible = true;
                this.title = title;
                this.message = message;
                if (_width && _height) {
                    this.containerWidth = (_width + 80) + "px";
                }
                if (callback) this._callback = callback;
            }
        }
    });

    return vue;
}

export { createDialog }
